<?xml version="1.0" encoding="UTF-8"?>
<!-- 
	old version imports, repalce with "xmlns:uml" and "xsi:schemaLocation" - RSingh 04/26/2010
	xmlns:Standard="http://www.eclipse.org/uml2/schemas/Standard/1" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:uml="http://schema.omg.org/spec/UML/2.1.1" 
 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" 
	xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
	xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" 
	exclude-result-prefixes="xmi ecore uml"
	xmlns:servU="xalan://gov.dhs.cis.soa.xslt.ServicesUtils" 
	xmlns:servO="xalan://gov.dhs.cis.soa.data.Service" 
	extension-element-prefixes="servU servO" >
	
	<xsl:output method="xml" indent="yes" />
	
	<xsl:param name="DELIM">|</xsl:param>
	<xsl:param name="NEWLN">&#10;</xsl:param>
	<xsl:param name="SERVOBJ" select="servO:new()"/>
	<xsl:template match="uml:Model">

<wbim:model xmlns:wbim="http://www.ibm.com/wbim/bomSchema1.0" schemaVersion="6.2.0">
  <wbim:catalogs>
    <wbim:resourceCatalogs>
      <wbim:catalog id="Rsrcs" name="Resources">
	      <!-- <wbim:catalog id="Generic" name="Generic Roles"/>  -->
	      <wbim:catalog id="Human" name="Human Roles"/>
	      <wbim:catalog id="System" name="System Roles"/>
	  </wbim:catalog>
    </wbim:resourceCatalogs>
    <wbim:processCatalogs>
      <wbim:catalog id="Services" name="Services">
        <wbim:catalog id="AKM" name="AKM"/>
        <wbim:catalog id="BCM" name="BCM"/>
        <!-- <wbim:catalog id="CS" name="CS"/>  -->
        <wbim:catalog id="ECM" name="ECM"/>
        <wbim:catalog id="IAM" name="IAM"/>
        <wbim:catalog id="RFM" name="RFM"/>
      </wbim:catalog>
    </wbim:processCatalogs>
	<wbim:classifierCatalogs>
		<wbim:catalog id="Clssfrs" name="Classifiers"/>
	</wbim:classifierCatalogs>
  </wbim:catalogs>
  <wbim:resourceModel>
    <wbim:roles>
		<xsl:for-each select="packagedElement[@name='001_Actors']">
			<xsl:for-each select="packagedElement[@xmi:type='uml:Actor']">
   				<xsl:text>&#10;</xsl:text>
				<wbim:role>
				<!-- 
				<xsl:variable name="rolekey" select="string(xmi:Extension/eAnnotations/details/@key)"/>
				 -->   				
				<xsl:variable name="rolekey" select="string(eAnnotations/details/@key)"/>
			      	<xsl:attribute name="name">
				      	<xsl:choose>
				      		<xsl:when test="$rolekey = 'System'"><xsl:text>System##</xsl:text></xsl:when>
				      		<xsl:when test="@name = 'USCIS System'"><xsl:text>System##</xsl:text></xsl:when>
				      		<!--
				      		<xsl:when test="$rolekey = 'Human'"><xsl:text>Human##</xsl:text></xsl:when>
				      		<xsl:otherwise><xsl:text>Human##</xsl:text></xsl:otherwise>
				      		 -->
				      		<xsl:otherwise><xsl:text>Human##</xsl:text></xsl:otherwise>
				      	</xsl:choose>
			      		<xsl:value-of select="@name"/>
			      	</xsl:attribute>
			      	<wbim:documentation><xsl:value-of select="ownedComment/body"/></wbim:documentation>
				</wbim:role>			      	
 		   </xsl:for-each>
 	   </xsl:for-each>
   				<xsl:text>&#10;</xsl:text>
    </wbim:roles>
  </wbim:resourceModel>
  <wbim:processModel>
    <wbim:services>
		<xsl:for-each select="packagedElement[@name='007_Services']">
			<xsl:for-each select="packagedElement[@xmi:type='uml:Class']">
   				<xsl:text>&#10;</xsl:text>
 	   			<xsl:value-of select="servU:initialize($SERVOBJ)"/>
				
				<xsl:variable name="servUMId" select="@xmi:id"/>
				
 	   			<xsl:value-of select="servU:parseName($SERVOBJ, string(@name))"/>
 	   			<xsl:value-of select="servU:parseStereoType($SERVOBJ, string(eAnnotations/details/@key))"/>

 	   			<xsl:value-of select="servU:parseDescription($SERVOBJ, string(ownedComment/body), string($DELIM))"></xsl:value-of>
				<xsl:for-each select="ownedAttribute">
	 	   			<xsl:value-of select="servU:parseAttribute($SERVOBJ, string(@name))"/>
   				</xsl:for-each>
   				
   				<!--
				<xsl:for-each select="ownedOperation">
					<xsl:variable name="servopname" select="@name"/>
					<xsl:for-each select="ownedParameter">
	 	   				<xsl:value-of select="servU:parseOperation($SERVOBJ, string($servopname), string(@direction), string(@name))"/>
	 	   			</xsl:for-each>
   				</xsl:for-each>
			 	-->
   				<!--  Select all associations WIPT & Release -->
				<xsl:for-each select="//packagedElement[@xmi:type='uml:Association']">
					<xsl:if test="contains(@xmi:id, $servUMId)">
	 	   				<xsl:value-of select="servU:parseAssociation($SERVOBJ, string(@xmi:id))"/>
	 	   			</xsl:if>
   				</xsl:for-each>
				<xsl:for-each select="//packagedElement[(@client=$servUMId) and (@xmi:type='uml:Dependency')]">
					<xsl:variable name="depname" select="@name"/>
					<xsl:variable name="supplierid" select="@supplier"/>
					<xsl:for-each  select="//packagedElement[@xmi:id=$supplierid]">
 	   					<xsl:value-of select="servU:parseDependency($SERVOBJ, string($depname), string(@name))"/>
 	   				</xsl:for-each>
   				</xsl:for-each>

   				<!-- <xsl:copy-of select="$NEWLN" />  -->
	<xsl:variable name="release" select="servU:getRelease($SERVOBJ)"/>
   	<xsl:if test="$release = 'A'">
      <wbim:service>
      	<xsl:attribute name="name">
      		<xsl:value-of select="servU:getNameForWBM($SERVOBJ, string($DELIM))"/>
      	</xsl:attribute>
      	<wbim:description><xsl:value-of select="servU:getDescForWBM($SERVOBJ)"/></wbim:description>
        <wbim:classifiers>
          <wbim:classifierValue>
	      	<xsl:attribute name="name">
	      		<xsl:variable name="extsyscall" select="servU:getExtsystem($SERVOBJ)"/>
		      	<xsl:choose>
		      		<xsl:when test="$extsyscall = 'NONE'"><xsl:text>Srvc32Ty##Internal</xsl:text></xsl:when>
		      		<xsl:otherwise><xsl:text>Srvc32Ty##External</xsl:text></xsl:otherwise>
		      	</xsl:choose>
	      	</xsl:attribute>
	      </wbim:classifierValue>
        </wbim:classifiers>
      </wbim:service>
     </xsl:if>
 		   </xsl:for-each>
 	   </xsl:for-each>
   				<xsl:text>&#10;</xsl:text>
    </wbim:services>
  </wbim:processModel>
  <wbim:classifierModel>
    <wbim:classifiers>
      <wbim:classifier id="Srvc32Ty" name="Clssfrs##Service Type">
        <wbim:classifierValue name="Srvc32Ty##External"/>
        <wbim:classifierValue name="Srvc32Ty##Internal"/>
      </wbim:classifier>
    </wbim:classifiers>
  </wbim:classifierModel>
</wbim:model>  
     </xsl:template>
</xsl:stylesheet>